package com.wtwd.campus.attendancereceiver;

import com.wtwd.campus.entity.MqAttendanceData;
import com.wtwd.campus.service.InjectFeignService;
import io.netty.channel.Channel;


public class IdentityReceiver implements AttendanceReceiver {
    @Override
    public String parseMessage(String data, Channel channel) {
        //首先进行校验位的校验
        boolean b = judgeSecurity(data);
        if(b){
            //校验成功，进行数据解析
            //先获取数据长度
            String dataLength = data.substring(4, 8);
            int length = convertToInt(dataLength)*2;
            String productNoStr = data.substring(8, 8 + length);
            String productNo = getProNo(productNoStr);
            String realProNo = convertProNo(productNo);
            MqAttendanceData mqAttendanceData=new MqAttendanceData();
            mqAttendanceData.setProductNo(realProNo);
            // 远程调用
            InjectFeignService.getIrmFeignClientService().attendanceRegistry(mqAttendanceData);
            return realProNo;
        }
        return null;
    }


}
